﻿module Test_utils
    open FSharpChess
    let pc_eql pc1 pc2 =
        if pc1.SquareOrd <> pc2.SquareOrd then false,"SquareOrd diff"
        elif pc1.Name <> pc2.Name then false,"Name diff"
        elif pc1.pcIsWhite <> pc2.pcIsWhite then false,"pcIsWhite diff"
        elif pc1.LastMoveTurnNo <> pc2.LastMoveTurnNo then false,"LastMoveTurnNo diff"
        elif pc1.NoOfMoves <> pc2.NoOfMoves then false,"NoOfMoves diff"
        elif pc1.HasBeenPromoted <> pc2.HasBeenPromoted then false,"HasBeenPromoted diff"
        elif pc1.ID <> pc2.ID then false,"ID diff"
        else true,""
    let psn_eql psn1 psn2 =
        let rec pcs_diff i =
            if i = psn1.Pcs.Length then
                true,""
            else
                let pcb,pcmess = pc_eql psn1.Pcs.[i] psn2.Pcs.[i]
                if not pcb then
                    false, (pcmess + " at sq " + i.ToString())
                else
                    pcs_diff (i+1)
        let pcsb,pcsmess = pcs_diff 0
        let rec sqs_diff i =
            if i = psn1.Sqs.Length then
                true,""
            elif psn1.Sqs.[i]<>psn2.Sqs.[i] then
                false, ("Sqs diff at " + i.ToString())
            else
                sqs_diff (i+1)
        let sqsb,sqsmess = sqs_diff 0
        if not pcsb then pcsb,pcsmess
        elif not sqsb then sqsb,sqsmess
        elif psn1.Hca <> psn2.Hca then false,"Hca diff"
        elif psn1.Hcb <> psn2.Hcb then false,"Hcb diff"
        elif psn1.Trn <> psn2.Trn then false,"Trn diff"
        elif psn1.Bcas <> psn2.Bcas then false,"Bcas diff"
        elif psn1.Wcas <> psn2.Wcas then false,"Wcas diff"
        elif psn1.Wct <> psn2.Wct then false,"Wct diff"
        elif psn1.Bct <> psn2.Bct then false,"Bct diff"
        elif psn1.Scr <> psn2.Scr then false,"Scr diff"
        elif psn1.PlayerToPlay.prIsWhite <> psn2.PlayerToPlay.prIsWhite then false,"PlayerToPlay diff"
        elif psn1.Mhst.Count <> psn2.Mhst.Count then false,"Mhst count diff"
        elif psn1.MhstStr.Count <> psn2.MhstStr.Count then false,"MhstStr count diff"
        else true,""
    
    
    
    
